package iterator

type Iterator interface {
	HasNext() bool
	GetNext() *User
}

type AnyIterator[T any] struct {
	index int //记录指针
	users []*T
}

func (u *AnyIterator[T]) HasNext() bool {
	return u.index < len(u.users)

}
func (u *AnyIterator[T]) GetNext() *T {
	if u.HasNext() {
		user := u.users[u.index]
		u.index++
		return user
	}
	return nil
}
